package org.budo.cmbc.direct.sdk.entity;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * @author lmw
 */
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
public class MEOccupationListQryResponse extends AbstractCmbcDirectResponse {
    private static final long serialVersionUID = 5020258523062411332L;

    private List<MEOccupation> list;

    public MEOccupationListQryResponse(String channelJnlNo, String responseJson) {
        super(channelJnlNo, responseJson);

        this.setList(new ArrayList<MEOccupation>());

        JSONObject jsonObject = JSON.parseObject(responseJson);
        JSONArray list = jsonObject.getJSONArray("List");
        for (Object _each : list) {
            JSONObject each = (JSONObject) _each;

            this.getList().add(new MEOccupation(each.getString("OctId"), //
                    each.getString("Type"), //
                    each.getString("Occupation"), //
                    each.getString("ParentOctId")));
        }
    }
}